package com.lzw.security.controller;

import com.lzw.security.entity.*;
import com.lzw.security.exception.MysqlUpdateException;
import com.lzw.security.exception.TidcNulException;
import com.lzw.security.ov.UserOV;
import com.lzw.security.service.AddService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020-3-28 22:12
 * @description：增加的请求的控制器
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/add")
public class AddController {
    @Autowired
    private AddService addService;
    @ApiOperation("增加一个类型 可选参数name url englishName")
    @CheckUpdate
    @PostMapping("/category")
    public UserOV<Integer> addCategory(@RequestBody Category category) throws MysqlUpdateException, TidcNulException {
        return addService.addCategory(category);
    }
    @ApiOperation("增加一个商品 除了销售量都能写")
    @CheckUpdate
    @PostMapping("/commodity")
    public UserOV<Integer> addCommodity(@RequestBody Commodity commodity) throws TidcNulException {
        return addService.addCommodity(commodity);
    }
    /**
     * create by: 冯涛滔
     * description: 增加一个秒杀商品
     * create time: 2020-3-29 20:48
     * @params [seckill]
     * @return com.lzw.security.ov.UserOV<java.lang.Integer>
     */
    @CheckUpdate
    @ApiOperation("增加一个秒杀商品 除了id都能填")
    @PostMapping("/seckill")
    public UserOV<Integer> addSecKill(@RequestBody Seckill seckill) throws TidcNulException {
        return addService.addSecKill(seckill);
    }
    @CheckUpdate
    @ApiOperation("增加一个配料 price代表这个配料要多少钱")
    @PostMapping("/dosing")
    public UserOV<Integer> addDosing(@RequestBody  Dosing dosing) throws TidcNulException {
        return addService.addDosing(dosing);
    }
    @CheckUpdate
    @ApiOperation("增加一个附属品 name type 1多选0就单选")
    @PostMapping("/accessory")
    public UserOV<Integer> addAccessory(@RequestBody  Accessory accessory) throws TidcNulException {
        return addService.addAccessory(accessory);
    }
    @CheckUpdate
    @ApiOperation("给一个商品连接一个附属品表 id和list里的id")
    @PostMapping("/commodity/accessory")
    public UserOV<Integer> addCommodityAccessory(@RequestBody CommodityAccessory commodityAccessory){
        return addService.addCommodityAccessory(commodityAccessory);
    }
    @CheckUpdate
    @ApiOperation("给附属品表增加多个配料 必填id和list数组")
    @PostMapping("/accessory/dosing")
    public UserOV<Integer> addAccessoryDosing(@RequestBody  AccessoryDosing accessoryDosing){
        return addService.addAccessoryDosing(accessoryDosing);
    }
    @CheckUpdate
    @ApiOperation("添加一个商品进购物车 除了id和金额都要 doings传一个字符串 1,2,3,4这样代表配料的id")
    @PostMapping("/cart")
    public UserOV<Integer> addCommodityInCart(@RequestBody Cart cart){
        return addService.addCommodityInCart(cart);
    }

    @CheckUpdate
    @ApiOperation("增加一种优惠卷 name type0满减1折扣 start多少钱才能用 discount减免多少钱或者多少折 ")
    @PostMapping("/coupon")
    public UserOV<Integer> addCoupon(@RequestBody Coupon coupon){
        return addService.addCoupon(coupon);
    }
    @CheckUpdate
    @ApiOperation("给一些用户发送某一张优惠卷 id优惠卷id users用户id数组")
    @PostMapping("/user/coupon")
    public UserOV<Integer> addUserCoupon(@RequestBody Coupon coupon){
        return addService.addCoupon(coupon);
    }

}
